<?php
$db = new Database();
if(isset($_POST['action'])){
    if($_POST['action']=="chooseCabinet"){
        $cabinetName = $db->escape($_POST['cabinetName']);
        $Getupload = $db->query("SELECT * FROM file WHERE cabinet={$cabinetName}","array");
        $a = 1;
        foreach($Getupload as $dateUploaded)
        {
           echo "<div class='title cursor uploadedImage' data-cabinet-name=".$cabinetName." style='text-indent:10px;height:40px;border-bottom:1px solid #ddd;' id='"."/".$dateUploaded['fileLocation']."' rel='".$dateUploaded['fileID']."'>";
           echo "<div class='left' style='margin-top:10px;' class='uploadedImagesName'>";
           echo $a++ . ". " . $dateUploaded['imageName'];
           echo "</div><div class='right'>";
           ?>
           <img src="/images/icon/delete.png"  class=" deleteImages fl_right" style="margin-top: 10px;" title="Delete this Image."rel="<?php echo $dateUploaded['fileID']; ?>"/>
           
           <?php
           echo "</div>";
           echo 
           "<br>";
           echo "</div>";
        }
    }elseif($_POST['action']=="getAllImages"){
        $cabinetName = $db->escape($_POST['cabinetName']);
        $getuploadedImages = $db->query("SELECT * FROM file WHERE cabinet={$cabinetName}","array");
        $getAll = $db->query("SELECT * FROM file WHERE cabinet={$cabinetName}","row");
        
        if($getAll['originalCabinet']==""){
            foreach($getuploadedImages as $image){
                echo '<img src="/'.$image['thumbnail'].'" width="217" class="dragImages"  data-image-id="'.$image['fileID'].'"/>';
            }
        }else{
            echo $getAll['originalCabinet'];
        }
        
    }
}
?>